﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZX.HIS.Common;

namespace ZX.HIS.UI.Controllers
{
    public class MeasuringUnitController : Controller
    {
        //
        // GET: /MeasuringUnit/

        public ActionResult Index()
        {
            return View();
        }
        public ActionResult UpateDrugage(int id)
        {
            ZX.HIS.Model.MeasuringUnit tt = new Model.MeasuringUnit();
            ZX.HIS.BLL.MeasuringUnit bll = new ZX.HIS.BLL.MeasuringUnit();
            List<ZX.HIS.Model.MeasuringUnit> tlist = bll.MeasuringUnitShow();
            tt = tlist.Where(p => p.MeasuringUnitId == id).FirstOrDefault();
            ViewData["tt"] = tt;
            return View("Index");
        }
        public ActionResult AddMeasuringUnit(ZX.HIS.Model.MeasuringUnit tt)
        {
            ZX.HIS.BLL.MeasuringUnit bll = new ZX.HIS.BLL.MeasuringUnit();
            if (bll.AddMeasuringUnit(tt) > 0)
            {
                return Content("<script>alert('添加成功');location.href='/MeasuringUnit/Index';</script>");
            }
            else
            {
                return Content("<script>alert('添加失败')</script>");
            }
        }
        public ActionResult MeasuringUnitUpt(ZX.HIS.Model.MeasuringUnit tt)
        {
            ZX.HIS.BLL.MeasuringUnit bll = new ZX.HIS.BLL.MeasuringUnit();
            if (bll.UpdateMeasuringUnit(tt) > 0)
            {
                return Content("<script>alert('修改成功');location.href='/MeasuringUnit/Index'</script>");
            }
            else
            {
                return Content("<script>alert('修改失败')</script>");
            }
        }
        public JsonResult FnMeasuringUnitList(int PageIndex, int PageSize)
        {
            ZX.HIS.BLL.MeasuringUnit bll = new ZX.HIS.BLL.MeasuringUnit();
            PageClass<ZX.HIS.Model.MeasuringUnit> tt = bll.PageMeasuringUnitList(PageIndex, PageSize);
            return Json(tt);
        }

    }
}
